﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gacn.ControleAlunos.Library.Entities;
using System.Data;
using Gacn.ControleAlunos.Library.DataAccess;

namespace Gacn.ControleAlunos.Library.Business
{
    public class CursoBiz
    {
        public static List<CursoEntity> GetAllCursoEntity()
        {
            List<CursoEntity> cursos = new List<CursoEntity>();

            DataTable dt = CursoDataAccess.GetAllCursoEntity();

            foreach (DataRow row in dt.Rows)
                cursos.Add(new CursoEntity(
                   long.Parse(row["idCurso"].ToString()),
                   row["NomeCurso"].ToString()
                 )
             );

            return cursos;
        }

        public static List<CursoDetalhadoEntity> GetAllCursoDetalhadoEntity()
        {
            List<CursoDetalhadoEntity> cursos = new List<CursoDetalhadoEntity>();

            DataTable dt = CursoDataAccess.GetAllCursoDetalhadoEntity();

            foreach (DataRow row in dt.Rows)
                cursos.Add(new CursoDetalhadoEntity(
                   long.Parse(row["idCurso"].ToString()),
                   row["NomeCurso"].ToString(),
                   row["chAbrevNomeCurso"].ToString(),
                   row["DescCurso"].ToString(),
                   DateTime.Parse(row["dtInsert"].ToString()),
                   Boolean.Parse(row["flgAtivo"].ToString()),
                   row["obs"].ToString(),
                   long.Parse(row["idInsertUser"].ToString())
                 )
             );

            return cursos;
        }
    }
}
